<?php

require_once '../../config.php';

$visitors = visitors_get_list();
            visitors_update_list($visitors);
?>

<table class="Dg">

  <tr>
    <td class="DgCell">Operators Chat</td>

    <td class="DgCell">&nbsp;</td>
    <td class="DgCell">&nbsp;</td>
    <td class="DgCell IconCell"><a href="#" class="ChatButton" rel=""><img src="/common/images/comment_16x16.png" /></a></td>
    <td class="DgCell IconCell">&nbsp;</td>
    <td class="DgCell IconCell">&nbsp;</td>
  </tr>

  <?php foreach ($visitors as $v): ?>
  <tr>
    <td class="DgCell"><?php echo $v['url'] ?></td>
    <td class="DgCell"><?php echo $v['windowState'] ?></td>
    <td class="DgCell IconCell"><?php echo $v['outgoingUnread'] ?></td>
    <td class="DgCell IconCell"><a href="#" class="ChatButton" rel="<?php echo $v['sessionId'] ?>"><img src="/common/images/comment_16x16.png" /></a></td>
    <td class="DgCell IconCell"><a href="#" class="ChatButton" rel="<?php echo $v['sessionId'] ?>"><img src="/common/images/cardfile_16x16.png" /></a></td>
    <td class="DgCell IconCell"><a href="#" class="ChatButton" rel="<?php echo $v['sessionId'] ?>"><img src="/common/images/notebook_16x16.png" /></a></td>
  </tr>
  <?php endforeach ?>
  
</table>

<script type="text/javascript">

  $('.ChatButton').each(function() {
    $(this).click(function(event) {
      $('#WorkspaceModule').attr('src', '/account/modules/chat.php?sessionId=' + event.currentTarget.rel);
    });
  });
  
</script>
